import { NgModule } from '@angular/core';
import { RouterModule, NavigationEnd, Router } from '@angular/router';
import { DataItemsComponent } from './data-items/data-items.component';
import { CodeRulesComponent } from './coderule/code-rules.component';
import { UserCardsComponent } from './user-card/user-cards.component';
import { CodeItemsComponent } from './code/code-items.component';
import { SystemInfoComponent } from './SystemInfo/systeminfo-code.component';
import { MeasurementUnitComponent } from './meaturement/measurement.component';

@NgModule({ 
    imports: [
        RouterModule.forChild([
            {
                path: '',
                children: [
                    { path: 'dataItems', component: DataItemsComponent },
                    { path: 'measurement', component: MeasurementUnitComponent },
                    { path: 'codeRules', component: CodeRulesComponent },
                    { path: 'codeItems', component: CodeItemsComponent },
                    { path: 'codeSystem', component: SystemInfoComponent },
                    { path: 'user-card', component: UserCardsComponent },
                ]
            }
        ])
    ],
    exports: [RouterModule]
})
export class BaseDataRoutingModule {
    constructor(private router: Router) {
        router.events.subscribe(event => {
            if (event instanceof NavigationEnd) {
                window.scroll(0, 0);
            }
        });
    }
}
